package com.bdqn.service.utils;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Component;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;

@Component
public class Email {
    @Autowired
    JavaMailSender mailSender;

    @Value("${spring.mail.username}")
    String username;

    public boolean getEmail(String email,String code) throws MessagingException {
        String name = email;

        String yzm = code;

        String em = "<div id=\"contentDiv\" onmouseover=\"getTop().stopPropagation(event);\" onclick=\"getTop().preSwapLink(event, 'html', 'ZC0718-pOAConh5nDhrhxBw6G_yOb3');\" style=\"position:relative;font-size:14px;height:auto;padding:15px 15px 10px 15px;z-index:1;zoom:1;line-height:1.7;\" class=\"body\">    <div id=\"qm_con_body\"><div id=\"mailContentContainer\" class=\"qmbox qm_con_body_content qqmail_webmail_only\" style=\"\">\n" +
                "<style>\n" +
                "  .qmbox .qmbox .qmbox .email-body {\n" +
                "    color: #40485B;\n" +
                "    font-size: 14px;\n" +
                "    font-family: -apple-system, \"Helvetica Neue\", Helvetica, \"Nimbus Sans L\", \"Segoe UI\", Arial, \"Liberation Sans\", \"PingFang SC\", \"Microsoft YaHei\", \"Hiragino Sans GB\", \"Wenquanyi Micro Hei\", \"WenQuanYi Zen Hei\", \"ST Heiti\", SimHei, \"WenQuanYi Zen Hei Sharp\", sans-serif;\n" +
                "    background: #f8f8f8; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .pull-right {\n" +
                "    float: right; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox a {\n" +
                "    color: #FE7300;\n" +
                "    text-decoration: underline; }\n" +
                "    .qmbox .qmbox .qmbox a:hover {\n" +
                "      color: #fe9d4c; }\n" +
                "    .qmbox .qmbox .qmbox a:active {\n" +
                "      color: #b15000; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .logo {\n" +
                "    text-align: center;\n" +
                "    margin-bottom: 20px; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .panel {\n" +
                "    background: #fff;\n" +
                "    border: 1px solid #E3E9ED;\n" +
                "    margin-bottom: 10px; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .panel-header {\n" +
                "    font-size: 18px;\n" +
                "    line-height: 30px;\n" +
                "    padding: 10px 20px;\n" +
                "    background: #fcfcfc;\n" +
                "    border-bottom: 1px solid #E3E9ED; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .panel-body {\n" +
                "    padding: 20px;\n" +
                "    line-height: 1.7; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .container {\n" +
                "    width: 100%;\n" +
                "    max-width: 600px;\n" +
                "    padding: 20px;\n" +
                "    margin: 0 auto; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .text-center {\n" +
                "    text-align: center; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .thumbnail {\n" +
                "    padding: 4px;\n" +
                "    max-width: 100%;\n" +
                "    border: 1px solid #E3E9ED; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .btn-primary {\n" +
                "    color: #fff;\n" +
                "    font-size: 16px;\n" +
                "    padding: 8px 14px;\n" +
                "    line-height: 20px;\n" +
                "    border-radius: 2px;\n" +
                "    display: inline-block;\n" +
                "    background: #FE7300;\n" +
                "    text-decoration: none; }\n" +
                "    .qmbox .qmbox .qmbox .btn-primary:hover, .qmbox .qmbox .qmbox .btn-primary:active {\n" +
                "      color: #fff; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .footer {\n" +
                "    color: #9B9B9B;\n" +
                "    font-size: 12px;\n" +
                "    margin-top: 20px; }\n" +
                "    .qmbox .qmbox .qmbox .footer a {\n" +
                "      color: #9B9B9B; }\n" +
                "      .qmbox .qmbox .qmbox .footer a:hover {\n" +
                "        color: #fe9d4c; }\n" +
                "      .qmbox .qmbox .qmbox .footer a:active {\n" +
                "        color: #b15000; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .email-body#mail_to_teacher {\n" +
                "    line-height: 26px;\n" +
                "    color: #40485B;\n" +
                "    font-size: 16px;\n" +
                "    padding: 0px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .container,.qmbox .qmbox .qmbox \n" +
                "    .email-body#mail_to_teacher .panel-body {\n" +
                "      padding: 0px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .container {\n" +
                "      padding-top: 20px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .textarea {\n" +
                "      padding: 32px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .say-hi {\n" +
                "      font-weight: 500; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph {\n" +
                "      margin-top: 24px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph .pro-name {\n" +
                "        color: #000000; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph.link {\n" +
                "      margin-top: 32px;\n" +
                "      text-align: center; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph.link .button {\n" +
                "        background: #4A90E2;\n" +
                "        border-radius: 2px;\n" +
                "        color: #FFFFFF;\n" +
                "        text-decoration: none;\n" +
                "        padding: 11px 17px;\n" +
                "        line-height: 14px;\n" +
                "        display: inline-block; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher ul.pro-desc {\n" +
                "      list-style-type: none;\n" +
                "      margin: 0px;\n" +
                "      padding: 0px;\n" +
                "      padding-left: 16px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher ul.pro-desc li {\n" +
                "        position: relative; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher ul.pro-desc li::before {\n" +
                "        content: '';\n" +
                "        width: 3px;\n" +
                "        height: 3px;\n" +
                "        border-radius: 50%;\n" +
                "        background: red;\n" +
                "        position: absolute;\n" +
                "        left: -15px;\n" +
                "        top: 11px;\n" +
                "        background: #40485B; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area {\n" +
                "      height: 600px;\n" +
                "      padding: 40px;\n" +
                "      background-image: url(https://gitee.com/wewin11235/upload-gitee-image/raw/master/bg.jpg);\n" +
                "      color: #FFFFFF; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .big-title {\n" +
                "        font-size: 32px;\n" +
                "        line-height: 45px;\n" +
                "        text-align: center; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .desc {\n" +
                "        margin-top: 8px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .desc p {\n" +
                "        margin: 0px;\n" +
                "        text-align: center;\n" +
                "        line-height: 28px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .card:nth-child(odd) {\n" +
                "        float: left;\n" +
                "        margin-top: 45px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .card:nth-child(even) {\n" +
                "        float: right;\n" +
                "        margin-top: 45px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .card .title {\n" +
                "        font-size: 18px;\n" +
                "        text-align: center;\n" +
                "        margin-bottom: 10px; }\n" +
                "      .yzm {\n" +
                "        font-size: 22px;\n" +
                "        color: blue;\n" +
                "</style>\n" +
                "<style type=\"text/css\">.qmbox .qmbox .qmbox style, .qmbox .qmbox .qmbox script, .qmbox .qmbox .qmbox head, .qmbox .qmbox .qmbox link, .qmbox .qmbox .qmbox meta {display: none !important;}</style>\n" +
                "<style>.qmbox .qmbox #mailContentContainer .txt {height:auto;}</style>\n" +
                "<style type=\"text/css\">.qmbox .qmbox style, .qmbox .qmbox script, .qmbox .qmbox head, .qmbox .qmbox link, .qmbox .qmbox meta {display: none !important;}</style><div id=\"mailContentContainer\" class=\"qmbox qm_con_body_content qqmail_webmail_only\" style=\"\">\n" +
                "\n" +
                "\n" +
                "<div id=\"contentDiv\" style=\"position:relative;font-size:14px;height:auto;padding:15px 15px 10px 15px;z-index:1;zoom:1;line-height:1.7;\" class=\"body\">    <div id=\"qm_con_body\"><div id=\"mailContentContainer\" class=\"qmbox qm_con_body_content qqmail_webmail_only\" style=\"\">\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "<div class=\"email-body\">\n" +
                "<div class=\"container\">\n" +
                "<div class=\"logo\">\n" +
                "<img height=\"70\" src=\"https://c-ssl.duitang.com/uploads/item/201511/17/20151117212458_PM5Az.png\">\n" +
                "</div>\n" +
                "<div class=\"panel\">\n" +
                "<div class=\"panel-header\">\n" +
                "通知\n" +
                "</div>\n" +
                "<div class=\"panel-body\">\n" +
                "<p>\n" +
                name+"，您好!\n" +
                "</p>\n" +
                "<p>\n" +
                "您的注册验证码为：<strong class=\"yzm\">"+ yzm +"</strong>\n" +
                "</p>\n" +
                "\n" +
                "\n" +
                "\n" +
                "</div>\n" +
                "</div>\n" +
                "<div class=\"footer\">\n" +
                "\n" +
                "</div>\n" +
                "</div>\n" +
                "</div>\n" +
                "\n" +
                "\n" +
                "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tbody><tr><td align=\"center\" style=\"overflow: hidden;font-size: 0;padding: 0;margin: 0;line-height: 0;\"><img style=\"width:0;height:0\" src=\"https://sctrack.sendcloud.net/track/open/eyJtYWlsbGlzdF9pZCI6IDAsICJ0YXNrX2lkIjogIiIsICJlbWFpbF9pZCI6ICIxNjE0OTQwNzQ4OTUwXzQyMTI5XzE1MTM5XzY4NTcuc2MtMTBfOV82M18xNjEtaW5ib3VuZDAkMTk5MDY1ODk1MkBxcS5jb20iLCAic2lnbiI6ICIzMDc4YTU2YzE4YWU5YTEyZDFkMTZhMTU2ZTk4MWNkOCIsICJ1c2VyX2hlYWRlcnMiOiB7fSwgImxhYmVsIjogMCwgInRyYWNrX2RvbWFpbiI6ICJzY3RyYWNrLnNlbmRjbG91ZC5uZXQiLCAicmVhbF90eXBlIjogIjAiLCAibmV0ZWFzZSI6ICJmYWxzZSIsICJvdXRfaXAiOiAiMTIwLjEzMi41NS41NiIsICJjb250ZW50X3R5cGUiOiAiMCIsICJ1c2VyX2lkIjogNDIxMjksICJvdmVyc2VhcyI6ICJmYWxzZSIsICJjYXRlZ29yeV9pZCI6IDEyMjI2OH0=.gif\"></td></tr></tbody></table><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tbody><tr><td align=\"center\" style=\"padding-top: 10px;\"><div style=\"border-top:1px solid #ddd;padding:10px;\"></div></td></tr></tbody></table></div></div></div>  <div></div>\n" +
                "</div>\n" +
                "<style type=\"text/css\">.qmbox style, .qmbox script, .qmbox head, .qmbox link, .qmbox meta {display: none !important;}</style></div></div><!-- --><style>#mailContentContainer .txt {height:auto;}</style>  </div>";

        try {
            System.out.println(username);
            System.out.println(mailSender);
            MimeMessage mimeMessage = mailSender.createMimeMessage();
            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
            helper.setFrom(username);     //发件人
            helper.setTo(email);       //收件人
            helper.setSubject("懒猫助手");             //标题
            helper.setText(em,true);           //邮箱内容
            mailSender.send(mimeMessage);
            return true;
        }catch (Exception e){
            e.printStackTrace();
            return false;
        }
    }

    public Integer forgetEmail(String email,String code) throws MessagingException {
        String name = email;

        String yzm = code;

        String em = "<div id=\"contentDiv\" onmouseover=\"getTop().stopPropagation(event);\" onclick=\"getTop().preSwapLink(event, 'html', 'ZC0718-pOAConh5nDhrhxBw6G_yOb3');\" style=\"position:relative;font-size:14px;height:auto;padding:15px 15px 10px 15px;z-index:1;zoom:1;line-height:1.7;\" class=\"body\">    <div id=\"qm_con_body\"><div id=\"mailContentContainer\" class=\"qmbox qm_con_body_content qqmail_webmail_only\" style=\"\">\n" +
                "<style>\n" +
                "  .qmbox .qmbox .qmbox .email-body {\n" +
                "    color: #40485B;\n" +
                "    font-size: 14px;\n" +
                "    font-family: -apple-system, \"Helvetica Neue\", Helvetica, \"Nimbus Sans L\", \"Segoe UI\", Arial, \"Liberation Sans\", \"PingFang SC\", \"Microsoft YaHei\", \"Hiragino Sans GB\", \"Wenquanyi Micro Hei\", \"WenQuanYi Zen Hei\", \"ST Heiti\", SimHei, \"WenQuanYi Zen Hei Sharp\", sans-serif;\n" +
                "    background: #f8f8f8; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .pull-right {\n" +
                "    float: right; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox a {\n" +
                "    color: #FE7300;\n" +
                "    text-decoration: underline; }\n" +
                "    .qmbox .qmbox .qmbox a:hover {\n" +
                "      color: #fe9d4c; }\n" +
                "    .qmbox .qmbox .qmbox a:active {\n" +
                "      color: #b15000; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .logo {\n" +
                "    text-align: center;\n" +
                "    margin-bottom: 20px; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .panel {\n" +
                "    background: #fff;\n" +
                "    border: 1px solid #E3E9ED;\n" +
                "    margin-bottom: 10px; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .panel-header {\n" +
                "    font-size: 18px;\n" +
                "    line-height: 30px;\n" +
                "    padding: 10px 20px;\n" +
                "    background: #fcfcfc;\n" +
                "    border-bottom: 1px solid #E3E9ED; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .panel-body {\n" +
                "    padding: 20px;\n" +
                "    line-height: 1.7; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .container {\n" +
                "    width: 100%;\n" +
                "    max-width: 600px;\n" +
                "    padding: 20px;\n" +
                "    margin: 0 auto; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .text-center {\n" +
                "    text-align: center; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .thumbnail {\n" +
                "    padding: 4px;\n" +
                "    max-width: 100%;\n" +
                "    border: 1px solid #E3E9ED; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .btn-primary {\n" +
                "    color: #fff;\n" +
                "    font-size: 16px;\n" +
                "    padding: 8px 14px;\n" +
                "    line-height: 20px;\n" +
                "    border-radius: 2px;\n" +
                "    display: inline-block;\n" +
                "    background: #FE7300;\n" +
                "    text-decoration: none; }\n" +
                "    .qmbox .qmbox .qmbox .btn-primary:hover, .qmbox .qmbox .qmbox .btn-primary:active {\n" +
                "      color: #fff; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .footer {\n" +
                "    color: #9B9B9B;\n" +
                "    font-size: 12px;\n" +
                "    margin-top: 20px; }\n" +
                "    .qmbox .qmbox .qmbox .footer a {\n" +
                "      color: #9B9B9B; }\n" +
                "      .qmbox .qmbox .qmbox .footer a:hover {\n" +
                "        color: #fe9d4c; }\n" +
                "      .qmbox .qmbox .qmbox .footer a:active {\n" +
                "        color: #b15000; }\n" +
                "  \n" +
                "  .qmbox .qmbox .qmbox .email-body#mail_to_teacher {\n" +
                "    line-height: 26px;\n" +
                "    color: #40485B;\n" +
                "    font-size: 16px;\n" +
                "    padding: 0px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .container,.qmbox .qmbox .qmbox \n" +
                "    .email-body#mail_to_teacher .panel-body {\n" +
                "      padding: 0px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .container {\n" +
                "      padding-top: 20px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .textarea {\n" +
                "      padding: 32px; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .say-hi {\n" +
                "      font-weight: 500; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph {\n" +
                "      margin-top: 24px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph .pro-name {\n" +
                "        color: #000000; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph.link {\n" +
                "      margin-top: 32px;\n" +
                "      text-align: center; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .paragraph.link .button {\n" +
                "        background: #4A90E2;\n" +
                "        border-radius: 2px;\n" +
                "        color: #FFFFFF;\n" +
                "        text-decoration: none;\n" +
                "        padding: 11px 17px;\n" +
                "        line-height: 14px;\n" +
                "        display: inline-block; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher ul.pro-desc {\n" +
                "      list-style-type: none;\n" +
                "      margin: 0px;\n" +
                "      padding: 0px;\n" +
                "      padding-left: 16px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher ul.pro-desc li {\n" +
                "        position: relative; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher ul.pro-desc li::before {\n" +
                "        content: '';\n" +
                "        width: 3px;\n" +
                "        height: 3px;\n" +
                "        border-radius: 50%;\n" +
                "        background: red;\n" +
                "        position: absolute;\n" +
                "        left: -15px;\n" +
                "        top: 11px;\n" +
                "        background: #40485B; }\n" +
                "    .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area {\n" +
                "      height: 600px;\n" +
                "      padding: 40px;\n" +
                "      background-image: url(https://gitee.com/wewin11235/upload-gitee-image/raw/master/bg.jpg);\n" +
                "      color: #FFFFFF; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .big-title {\n" +
                "        font-size: 32px;\n" +
                "        line-height: 45px;\n" +
                "        text-align: center; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .desc {\n" +
                "        margin-top: 8px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .desc p {\n" +
                "        margin: 0px;\n" +
                "        text-align: center;\n" +
                "        line-height: 28px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .card:nth-child(odd) {\n" +
                "        float: left;\n" +
                "        margin-top: 45px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .card:nth-child(even) {\n" +
                "        float: right;\n" +
                "        margin-top: 45px; }\n" +
                "      .qmbox .qmbox .qmbox .email-body#mail_to_teacher .blackboard-area .card .title {\n" +
                "        font-size: 18px;\n" +
                "        text-align: center;\n" +
                "        margin-bottom: 10px; }\n" +
                "      .yzm {\n" +
                "        font-size: 22px;\n" +
                "        color: blue;\n" +
                "</style>\n" +
                "<style type=\"text/css\">.qmbox .qmbox .qmbox style, .qmbox .qmbox .qmbox script, .qmbox .qmbox .qmbox head, .qmbox .qmbox .qmbox link, .qmbox .qmbox .qmbox meta {display: none !important;}</style>\n" +
                "<style>.qmbox .qmbox #mailContentContainer .txt {height:auto;}</style>\n" +
                "<style type=\"text/css\">.qmbox .qmbox style, .qmbox .qmbox script, .qmbox .qmbox head, .qmbox .qmbox link, .qmbox .qmbox meta {display: none !important;}</style><div id=\"mailContentContainer\" class=\"qmbox qm_con_body_content qqmail_webmail_only\" style=\"\">\n" +
                "\n" +
                "\n" +
                "<div id=\"contentDiv\" style=\"position:relative;font-size:14px;height:auto;padding:15px 15px 10px 15px;z-index:1;zoom:1;line-height:1.7;\" class=\"body\">    <div id=\"qm_con_body\"><div id=\"mailContentContainer\" class=\"qmbox qm_con_body_content qqmail_webmail_only\" style=\"\">\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "\n" +
                "<div class=\"email-body\">\n" +
                "<div class=\"container\">\n" +
                "<div class=\"logo\">\n" +
                "<img height=\"70\" src=\"https://c-ssl.duitang.com/uploads/item/201511/17/20151117212458_PM5Az.png\">\n" +
                "</div>\n" +
                "<div class=\"panel\">\n" +
                "<div class=\"panel-header\">\n" +
                "通知\n" +
                "</div>\n" +
                "<div class=\"panel-body\">\n" +
                "<p>\n" +
                name+"，您好!\n" +
                "</p>\n" +
                "<p>\n" +
                "您的注册验证码为：<strong class=\"yzm\">"+ yzm +"</strong>\n" +
                "</p>\n" +
                "\n" +
                "\n" +
                "\n" +
                "</div>\n" +
                "</div>\n" +
                "<div class=\"footer\">\n" +
                "\n" +
                "</div>\n" +
                "</div>\n" +
                "</div>\n" +
                "\n" +
                "\n" +
                "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tbody><tr><td align=\"center\" style=\"overflow: hidden;font-size: 0;padding: 0;margin: 0;line-height: 0;\"><img style=\"width:0;height:0\" src=\"https://sctrack.sendcloud.net/track/open/eyJtYWlsbGlzdF9pZCI6IDAsICJ0YXNrX2lkIjogIiIsICJlbWFpbF9pZCI6ICIxNjE0OTQwNzQ4OTUwXzQyMTI5XzE1MTM5XzY4NTcuc2MtMTBfOV82M18xNjEtaW5ib3VuZDAkMTk5MDY1ODk1MkBxcS5jb20iLCAic2lnbiI6ICIzMDc4YTU2YzE4YWU5YTEyZDFkMTZhMTU2ZTk4MWNkOCIsICJ1c2VyX2hlYWRlcnMiOiB7fSwgImxhYmVsIjogMCwgInRyYWNrX2RvbWFpbiI6ICJzY3RyYWNrLnNlbmRjbG91ZC5uZXQiLCAicmVhbF90eXBlIjogIjAiLCAibmV0ZWFzZSI6ICJmYWxzZSIsICJvdXRfaXAiOiAiMTIwLjEzMi41NS41NiIsICJjb250ZW50X3R5cGUiOiAiMCIsICJ1c2VyX2lkIjogNDIxMjksICJvdmVyc2VhcyI6ICJmYWxzZSIsICJjYXRlZ29yeV9pZCI6IDEyMjI2OH0=.gif\"></td></tr></tbody></table><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\"><tbody><tr><td align=\"center\" style=\"padding-top: 10px;\"><div style=\"border-top:1px solid #ddd;padding:10px;\"></div></td></tr></tbody></table></div></div></div>  <div></div>\n" +
                "</div>\n" +
                "<style type=\"text/css\">.qmbox style, .qmbox script, .qmbox head, .qmbox link, .qmbox meta {display: none !important;}</style></div></div><!-- --><style>#mailContentContainer .txt {height:auto;}</style>  </div>";

        try {
            System.out.println(username);
            System.out.println(mailSender);
            MimeMessage mimeMessage = mailSender.createMimeMessage();
            MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, true);
            helper.setFrom(username);     //发件人
            helper.setTo(email);       //收件人
            helper.setSubject("懒猫助手");             //标题
            helper.setText(em,true);           //邮箱内容
            mailSender.send(mimeMessage);
            return 1;
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }
}
